home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / DISEEK.C < prev    next >
C/C++ Source or Header  |  1995-09-20  |  3KB  |  89 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    diseek.c
  5. //   Title:    Data File I/O Library
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //
  24. //    This module contains code to position the file pointer in a virtual file.
  25. //
  26. //    The code in this module should be written entirely in C. 
  27. //    Do not use any C++ constructs.
  28. //
  29. //    This module is portable to:
  30. //        DOS 3.X+
  31. //        MS Windows 3.X+
  32. //        OS/2 2.X+
  33. //        OS/2 2.0 PM
  34. //        SCO UNIX.
  35. //
  36. //    The following compilers are supported:
  37. //        MSC 6.0A
  38. //        MSC/C++ 7.0
  39. //        Borland C++ 3.1 for DOS
  40. //        Borland C++ 1.0 for OS/2 2.X
  41. //        SCO UNIX cc
  42. //
  43. //----------------------------------------------------------------------------
  44. #include <di.h>
  45.  
  46.  
  47. //----------------------------------------------------------------------------
  48. //   Description:    Position file pointer in a random access file.
  49. //    Parameters:    hlf     Logical file handle
  50. //                        fpos    File position to seek to.
  51. //       Returns:    TRUE if successful.
  52. //----------------------------------------------------------------------------
  53. BOOL FN_E DioSeek(HLF hlf, FPOS fpos)
  54. {
  55.     Assert(hlf >= 0 && hlf < MAX_LOGICAL_FILES);
  56.     Assert(di.logical[hlf].fUsed);
  57.  
  58.     if (fpos < 0)
  59.          fpos = 0;
  60.     di.logical[hlf].fl &= ~LF_EOF;
  61.     if ((unsigned)fpos >= di.logical[hlf].flen)
  62.         {
  63.         fpos = di.logical[hlf].flen;
  64.         di.logical[hlf].fl |= LF_EOF;
  65.         }
  66.     di.logical[hlf].fpos = fpos;
  67.     return TRUE;
  68. }
  69.  
  70.  
  71. //----------------------------------------------------------------------------
  72. //   Description:    Position file pointer in a block file.
  73. //    Parameters:    hlf         Logical file handle
  74. //                        usBlock    Block to seek to
  75. //       Returns:    TRUE if successful.
  76. //----------------------------------------------------------------------------
  77. BOOL FN_E DioSeekBlock(HLF hlf, LONG lBlock)
  78. {
  79.     FPOS fpos;
  80.  
  81.     Assert(hlf >= 0 && hlf < MAX_LOGICAL_FILES);
  82.     Assert(di.logical[hlf].fUsed);
  83.     fpos = (FPOS)lBlock * (FPOS)di.logical[hlf].usBlockSize;
  84.     return DioSeek(hlf, fpos);
  85. }
  86. //----------------------------------------------------------------------------
  87. //------------------------------- End of File --------------------------------
  88. //----------------------------------------------------------------------------
  89.